<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/4
 * Time: 13:39
 */

namespace app\index\controller;
use think\Controller;
use think\Db;
class Intro extends Controller
{
    public function index(){
        $base=Db::name("base")->select();
        $this->assign("base",$base);
        $comment=Db::name("comments")->select();
        $this->assign("comments",$comment);
        return $this->fetch();
    }
    public function add(){
        $content = input('content');
        if(request()->isPost()){
            $data=['content'=>input('param.content')];
        }
        //存入数据库
        if ($content!=null){
            $res=Db::name("comments")->insert($data);
            if($res){
                $this->success("添加留言成功");
            }
            else{
                $this->error("添加留言失败");
            }
        }else{
            $this->error("不能为空");
        }

    }
}